home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / gem / l_1199 / 970 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  15.6 KB

  1. Date: Fri, 22 Jul 94 03:11 CDT
  2. From: ekl@sdf.lonestar.org (Evan K. Langlois)
  3. To: gem-list@world.std.com
  4. Subject: GEM apps, in general
  5. Precedence: bulk
  6.  
  7.  
  8. I'll post some code in my next message that handles button events.  Please
  9. compile it.  It demonstrates soem very simple and powerful ideas.  In fact,
  10. remove the printf's and stick in pointers to functions and you'll have a
  11. C program that manages button events very well.  Use ObjC messages for the
  12. printf's and it gets better.
  13.  
  14. The idea of the code is to show that you don't need to call graf_mkstate()
  15. a bunch of times in a loop.  How many art packages look for a click and 
  16. then call graf_mkstate() in a loop?   This prevents any other events and
  17. its wrong.  You can use timer events to animate an icon, and rectangle
  18. events for other effects, and still recieve redraw messages and such while
  19. a user is holding a button down - even recieve more button events!!
  20.  
  21. Now, why is holding the right mouse button down to click in a background
  22. window archaic?  Well, I think that holding the right button will stop
  23. a TOP message from being delivered (I don't remember nor care) and I know
  24. that until recently, most people did not know that GEM could handle more
  25. than one button at once without polling.
  26.  
  27. If the user clicks the mouse on a selectable and completely unobscured,
  28. visible object, then why not select it instead of topping the window?  Since
  29. there is a border area on most dialogs, you can use that to top it, and
  30. and partially obscured object can be used to top the window.  I know some
  31. of you are worried about not being to top a window - does the new condition
  32. or forcing the object to be completely visible satisfy your needs?
  33.  
  34. As for key events and the "top" window, you should note that the top window
  35. does always get key events - if you call a dialog a window (even a modal one).
  36. Also note that if you select something in the menu, like change font, then
  37. this affects the top window too .. but what if you have a dialog over that
  38. window?   What if "Change Font" calls up a dialog in a window?  If won't
  39. change the font of itself!!  It changes the font of a different window.
  40. Application focus and key focus are not always different.   
  41.  
  42. As for the sending of key events, I would like to propose an extension to
  43. the drag-drop protocol.  If you implement a drag, but the application you
  44. drag to doesn't support being dropped on, then you can still "pipe" ascii
  45. data to that window by sending a key event to the application for each
  46. character.  This will be painfully slow, but it will work.
  47.  
  48. As for point to type, make it an option in the app-defs file.  Its easy to
  49. do for one application, but making it global is kinda screwy as its basically
  50. doing finding the window, finding the app that owns the window, like drag/drop
  51. but then it sends a copy of teh key event the OS sent to the other app.
  52.  
  53. As to Ken and WinLIB Pro:
  54.  
  55. ========================================================================
  56. I'm simply saying that the foreground application gets more 'attention'
  57. than background tasks. No 'wasted' CPU time at all, just 're-allocated' CPU
  58. time. After all, the application the user is currently interacting with will
  59. be getting most of the mouse activity, don't you think? :-)
  60. ========================================================================
  61.  
  62. This statement is WRONG.  There are no foreground and background tasks.
  63. Think of it this way.  An application waiting for an event is not running
  64. and is not using the CPU.  An application that is executing code is
  65. running.  Under SingleTOS, or Geneva, while one application runs, no
  66. other application can be running, and when the AES is called, GEM begins
  67. to poll for events and either gives an event where it needs to, or lets the
  68. AES call return.  It determines things like how much two cuncurrent programs,
  69. like a DESK ACC and an APP (or with GENEVA multiple apps) on a round-robin
  70. basis, so every program gets more or less EQUAL CPU share.  Task switching
  71. only happens during an AES call.
  72.  
  73. Under MultiTOS, multiple applications runs at once, so when does the AES
  74. poll for events?  Answer - always.  Having programs run while another
  75. polls makes MultiTOS seem very slow, even if only one application is
  76. running, and more applications running means more code running at once.
  77. What is some of those programs don't block for evnt_multi and they use
  78. a 0ms timer to poll for events?   Well they will wind up using ALOT of
  79. CPU time slowing the system to a baby-crawl.  Just evnt_multi calling
  80. very often is ALOT of overhead, and then calling objc_find is worse.
  81. Doing all this during the MultiTOS polling is too much to handle.  And
  82. don't forget that you can have tasks that aren't GEM, and they will
  83. have to complete for CPU time too!!
  84.  
  85. Under the newer MultiTOS, instead of polling for events, interrupts trigger
  86. MiNT device drivers that wake up the AES and let it know an event is
  87. available.  This is ver yfast and efficient and it means that there is no
  88. more polling.  No polling means that when your app runs, it doesn't have to
  89. compete with the AES code polling the mouse in a tight loop, so it runs
  90. fast.  Also note that in neither version of MultiTOS do you need to give
  91. up CPU time.  You can do computations all day long and never make an AES
  92. call and the system will be fine (your windows get dirty though!).  Heavy
  93. computation is a good reason to use tfork() - it is backwards compatible
  94. to TOS (making it a single-tasking function call) and allow you to thread
  95. a long function call.
  96.  
  97. Using Timer events to poll means that one application will east CPU slices
  98. from every other program - those in windows, TOS background tasks, daemons,
  99. or other AES programs that attempt to do concurrent tasks.  These events
  100. are made by a programmer that assumes the user is using his program and
  101. is not using any other, and that the performance of the rest of the system
  102. is allowed to suffer to make his life easier.
  103.  
  104. This is simply bad programming.  There are better ways.  In General, your
  105. programs should always sit and wait for something to happen, NOT check and
  106. see if something is happening.  The first is highly efficient and is just
  107. as fast under single-TOS and will free an incredible amount of CPU under
  108. the new MultiTOS.  The second will be great under single-TOS, slow under
  109. MultiTOS and you will see it HOG the CPU under the new MultiTOS using simple
  110. utils like TOP.
  111.  
  112. ========================================================================
  113. I do not like the idea of having buttons function in background windows
  114. unless that particular dialog is INTENDED to work that way.  There should
  115. be options for doing this for things like tool boxes and multiple
  116. non-overlapping pannels, but otherwise, I like the way GEM works normally.
  117. ========================================================================
  118.  
  119. Give examples of where the guidelines I give above fail!  Using the desktop
  120. as a test, I only see benefits.
  121.  
  122. ========================================================================
  123. I'm not sure I follow your comment.  My -experience- is that I do not know
  124. assembly language, and therefore have no real use for an assembly level
  125. debugger.  What on earth can you possibly object to in that?
  126. ========================================================================
  127.  
  128. In my EXPERIENCE I have used both kinds of debuggers.  Both have their
  129. uses.  I do know assembly language, 3 or 4 of them, but I fail to see
  130. what ANY of this has to do with GEM.  Will using TIMER events slow the
  131. system?  Yes!   Why?   Because the program is running instead of waiting.
  132. Waiting means you are on a queue, ready for some other code to give you
  133. your fix so you jive again :-)   Running means your eating CPU and if you
  134. east CPU, you better do something GOOD with it since its limited resource.
  135. TIMER events are sent to every app that wants them, not just the top one.
  136. Calling evnt_multi means passing half a dozen parameters on the stack,
  137. including lots of LEA's, then copy lots of these to the intin/intout arrays,
  138. then lookup the control values to the calls (whoops, missed a JSR in there!
  139. this ain't C++, so its not inline), then we call a TRAP (and that takes
  140. forever in itself), now the return array has to have its values copied to
  141. the pointers that were passwd, we play with some reggies, and then do a
  142. RTS.  Evnt_multi finished, now do wind_find and objc_find and then go back
  143. to evnt_multi.  Do all this in a tight loop, never stopping.  Why do
  144. all this jumping around and memory copying?  Most OSs see your program
  145. working, and other apps aren't so much, so you get lots of CPU time, and
  146. when other apps are asking for lots of time, you get 96% or so.  When
  147. other apps want time, you get %80, others get maybe %20, but that's about
  148. all they need (they run slow, but useable).
  149.  
  150. Now, we do all this?  The app can wait for specific events and let programs
  151. that NEED to use the CPU use it.  Sure, you still have to call evnt_multi
  152. and all the rest, but not as fast as you possible can!!   That is not
  153. event driven!   That is polling.  Polling is what made MultiTOS such a dog.
  154. Why do it in your applications?  Don't bitch at ATARI if your gonna make
  155. the same lazy mistakes!!
  156.  
  157. So, do us all a favor, and work to illimintae polling from your apps.
  158.  
  159. ========================================================================
  160. * I found that by collecting rectangles, it is perfectly feasible to
  161.   blit-scroll a background window, and it is potentially faster,
  162. ========================================================================
  163.  
  164. Of course, rectangles are just 4 words, or a pointer to 4 words.  Using
  165. them is easy.  Drawing graphics for a large pixel-map takes a considerable
  166. amount of CPU power.  The overhead of the rectangles is nothing by
  167. comparison.  That is why I use point-to-type and let my background windows
  168. scroll in TOSWIN.
  169.  
  170. ========================================================================
  171. Hey, whatever happened to our discussion of color-palette handling?  I
  172. especially likes my ideas.  :)  Could someone go back to those old
  173. messages and digest what was discussed?
  174. ========================================================================
  175.  
  176. What was your idea?
  177.  
  178. ========================================================================
  179. A smart malloc() should use an adaptive algorithm when choosing hunk sizes
  180. to Malloc() (I believe the current gcc libc malloc does this()).
  181. ========================================================================
  182.  
  183. 8K chunks is best.   When running protected all memory is dolled out in
  184. 8K chunks anyway, so you might as well only Malloc() in that size.
  185.  
  186. ========================================================================
  187. I thought there IS a program which patched MultiTOS to do all (even in the
  188. desktop!) dialogs in windows!
  189. ========================================================================
  190.  
  191. It's called multidial, but I don't know about the desktop.  Its a simple
  192. program really, but so many programs call form_do() all funky that it can
  193. be hard to configure (you can configure it per application).  I'll have to
  194. see where to find that again.  I think I'm gonna start using it.  I don't
  195. think it fixed the desktop though - maybe fileselector.
  196.  
  197. ========================================================================
  198. I think you have to go visit them, and slap them real hard with the
  199. guidelines for writing multitasking-ready GEM applications.
  200. ========================================================================
  201.  
  202. 1 - No Polling
  203. 2 - No vector grabbing!
  204. 3 - All graphics in windows (including window 0 with proper wind_set)
  205. 4 - Always walk rectangles
  206. 5 - Don't assume screen or memory formats.
  207. 6 - Free unused memory
  208. 7 - No polling!
  209. 8 - No vector grabbing!
  210. 9 - No form_do() or other locking calls.
  211. 10 - no dialog-ware or alert-ware
  212.  
  213. ========================================================================
  214. IMHO they provide valuable feed-back to the user, ie, "Is my program
  215. crashed, or just taking an hour to <foo>?"
  216. ========================================================================
  217.  
  218. Buy an AdSpeed, then if it takes more than 40 minutes to <foo>, either
  219. the application crashed, or the AdSpeed needs to be reseated and everything
  220. has crashed.  This way I get to know if machine has dies 20 minutes early,
  221. so I can open the machine and mess with screws for 30 minutes!  Actually,
  222. I have since hand-bent every pin on my CPU socket to make better contact
  223. and have had no further complaint.
  224.  
  225. ========================================================================
  226. This sort of thing is really the domain of the window manager, and should
  227. be selectable by the user. On workstations I much prefer to have mouse
  228. focus (window under mouse gets key events, topped or otherwise), but on the
  229. Falcon I'm kind of used to having to top a window.
  230. ========================================================================
  231.  
  232. I think selectable by the user says it all!
  233. ========================================================================
  234. And how do you see this working? The applications need to be changed as well,
  235. or putting the forms in windows is going to do nothing more than giving them
  236. a border. If you've got a form that can stay up whilst the rest of the program
  237. is running then you're program has got to be able to accept events from it
  238. at any time. There's no way the OS could do this for you.
  239. ========================================================================
  240.  
  241. Nope, tops go to form window, menu bar stays, but obviously, menu select
  242. messages don't take effect until after form window is closed.  You can
  243. top windows for other apps and run ACCs, but any top of the app that called
  244. form_do gets that form window topped.
  245.  
  246. It works, but forms within forms (like poor pop-ups) can get messy.
  247.  
  248. ========================================================================
  249. If an ACC doesn't call menu_register, does it still take up a `slot'?
  250. ========================================================================
  251.  
  252. Depends  on the internals of GEM.  Good question!!!  I can't answer that.
  253.  
  254. ========================================================================
  255. Is there some standard way of lynching software authors, and does anyone
  256. know Pradip's address?  (Atari Works uses forms for almost everything,
  257. including the printing progress dialog!!!  Forget multitasking with AW).
  258. ========================================================================
  259.  
  260. Warwick!  For shame!!  You should know that the VDI is not re-entrant!
  261. You can't switch tasks while the VDI is printing a page!   Worse yet,
  262. the VDI writes to printer by calling the semi-re-entrant BIOS, which
  263. means that a 1MB super-density graphics print of 1 or 2 pages will
  264. make a BIOS call at LEAST 1 MILLION TIMES!!   BIOS is bad.  When you
  265. need more than a couple bytes, please use GEMDOS.   GEMDOS is so much
  266. faster, but the VDI doesn't know that, and making better VDI drivers
  267. won't help since the VDI isn't re-entrant anyway!
  268.  
  269. Actually, I CAN spool VDI output with MiNT and my spooler, but all those
  270. BIOS calls writing to the pipe cloggs up the system, so it takes almost
  271. as long as printing to spool it!!   Then printing goes well, and you have
  272. great control over that spool file, but you have to wait for it to print
  273. AFTER you wait for it to spool :-(.  Printing happens simultaneously with
  274. something else, but printing doesn't start until the spooling is done.
  275. I'm not sure how to fix it, other than to drop support for /dev/centr
  276. so I can speed up printer output.  /dev/centr locks the system so you got
  277. to use small chunks to multitask, but /dev/lp is buffered and interrupt
  278. driven, so I can throw a 12-24K chunk at it whenever I need to.
  279.  
  280. ========================================================================
  281. Using a form for progress is MAJORLY BAD, because it is just that time
  282. that the user will want to switch to some other application.
  283. ========================================================================
  284.  
  285. An iconifyable window is best.
  286.  
  287. ~.
  288.  
  289.